/*
 * Copyright 2013 Paul-Martin Koeckeritz & Christoph Hellmich
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.hsos.samcomm.userManagement.boundary.jsf;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;

/**
 * Invalidate user session.
 *
 * @author Paul-Martin Koeckeritz & Christoph Hellmich
 * @version 02/14/2013
 */
@ManagedBean(name = "logoutBean")
@RequestScoped
public class LogoutBean {
    static private String GO_AFTER_LOGOUT = "/login.xhtml?faces-redirect=true";
    
    public String logout() {
        ExternalContext ectx = 
                FacesContext.getCurrentInstance().getExternalContext();
        ectx.invalidateSession();
        return GO_AFTER_LOGOUT;
    }
}